package lu.med.praxiswahl.wahlumed.client.ordonancen;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JCheckBox;
import javax.swing.JOptionPane;

/**
 * 
 * @author Lars Holger Roth
 */
public class OrdonancenCheckBoxListener implements ActionListener
{
    public static final int MODE_ADRESSE = 0;
    public static final int MODE_DATUM = 1;

    private int mode = -1;
    private OrdonancenPanel owner;
    private JCheckBox comp;

    public OrdonancenCheckBoxListener(OrdonancenPanel owner, JCheckBox comp,
	    int mode)
    {
	this.owner = owner;
	this.comp = comp;
	this.mode = mode;
    }

    public void actionPerformed(ActionEvent e)
    {
	if (mode == MODE_ADRESSE)
	{
	    owner.setPrintAdresse(comp.isSelected());
	}
	else if (mode == MODE_DATUM)
	{
	    owner.setPrintDatum(comp.isSelected());
	}
	else
	{
	    JOptionPane.showMessageDialog(null,
		    "Schwerwiegender interner Fehler");
	}
    }

}
